package com.gxa.hualian.service.impl;

import com.gxa.hualian.dao.CouponDao;
import com.gxa.hualian.dao.impl.CouponImpl;
import com.gxa.hualian.entity.Coupon;
import com.gxa.hualian.service.CouponService;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class CouponServiceImpl implements CouponService {
    private CouponDao couponDao=new CouponImpl();
    @Override
    public List<Coupon> selectByPage(Integer page, Integer limit) throws Exception {
        return couponDao.selectByPage(page,limit);
    }

    @Override
    public List<Coupon> sellectAll() throws Exception {
        return couponDao.selectAll();
    }

    @Override
    public Integer insert(Coupon coupon) throws Exception {
        return couponDao.insert(coupon);
    }

    @Override
    public Integer update(Coupon coupon) throws Exception {
        return couponDao.update(coupon);
    }

    @Override
    public Coupon sellectById(Integer id) throws Exception {
        return couponDao.selectById(id);
    }

    @Override
    public Map<String, List<Coupon>> getConListForWeb(String phone) throws Exception {
        List<Coupon> userGetCpnList = couponDao.userGetCpnList(phone);
        List<Coupon> userNotGetCpnList = couponDao.userNotGetCpnList(phone);
        List<Coupon> overExpire = couponDao.overExpire(phone);
        Map<String,List<Coupon>> map=new HashMap<>();
        map.put("userGetCpnList",userGetCpnList);
        map.put("userNotGetCpnList",userNotGetCpnList);
        map.put("overExpire",overExpire);
        return map;
    }
}
